import 'dart:convert' show json;

class StoryDetail {

  int id;
  int type;
  String body;
  String ga_prefix;
  String image;
  String image_source;
  String share_url;
  String title;
  List<String> css;
  List<String> images;
  List<String> js;

  StoryDetail.fromParams({this.id, this.type, this.body, this.ga_prefix, this.image, this.image_source, this.share_url, this.title, this.css, this.images, this.js});

  factory StoryDetail(jsonStr) => jsonStr == null ? null : jsonStr is String ? new StoryDetail.fromJson(json.decode(jsonStr)) : new StoryDetail.fromJson(jsonStr);

  StoryDetail.fromJson(jsonRes) {
    id = jsonRes['id'];
    type = jsonRes['type'];
    body = jsonRes['body'];
    ga_prefix = jsonRes['ga_prefix'];
    image = jsonRes['image'];
    image_source = jsonRes['image_source'];
    share_url = jsonRes['share_url'];
    title = jsonRes['title'];
    css = jsonRes['css'] == null ? null : [];

    for (var cssItem in css == null ? [] : jsonRes['css']){
      css.add(cssItem);
    }

    images = jsonRes['images'] == null ? null : [];

    for (var imagesItem in images == null ? [] : jsonRes['images']){
      images.add(imagesItem);
    }

    js = jsonRes['js'] == null ? null : [];

    for (var jsItem in js == null ? [] : jsonRes['js']){
      js.add(jsItem);
    }
  }

  @override
  String toString() {
    return '{"id": $id,"type": $type,"body": ${body != null?'${json.encode(body)}':'null'},"ga_prefix": ${ga_prefix != null?'${json.encode(ga_prefix)}':'null'},"image": ${image != null?'${json.encode(image)}':'null'},"image_source": ${image_source != null?'${json.encode(image_source)}':'null'},"share_url": ${share_url != null?'${json.encode(share_url)}':'null'},"title": ${title != null?'${json.encode(title)}':'null'},"css": $css,"images": $images,"js": $js}';
  }
}

